package per.dj.testpro.entity.protocol;

import lombok.Data;

import java.util.List;

@Data
public class Qy_0B implements IMessageBody{

    //主控板故障码
    private String boardFailureCode;

    //充电口数
    private Integer portNum;

    private List<Qy_0B_SON> qy0BSonsList;;

    public final byte[] WriteToBytes() {
        return null;
    }

    public final void ReadFromBytes(byte[] messageBodyBytes) {

        setBoardFailureCode(String.format("%02X", messageBodyBytes[0])+
                String.format("%02X", messageBodyBytes[1])+
                String.format("%02X", messageBodyBytes[2])+
                String.format("%02X", messageBodyBytes[3]));
        setPortNum(Integer.valueOf(String.format("%02X", messageBodyBytes[4]),16));

        Qy_0B_SON qy0BSon = null;
        for(int i=0;i<getPortNum();i++){
            qy0BSon = new Qy_0B_SON();
            qy0BSon.setPortError(String.format("%02X", messageBodyBytes[5+4*i])+
                    String.format("%02X", messageBodyBytes[6+4*i])+
                    String.format("%02X", messageBodyBytes[7+4*i])+
                    String.format("%02X", messageBodyBytes[8+4*i]));
            qy0BSonsList.add(qy0BSon);
        }
    }
}
